<!--
 * @Descripttion: 测试class方法
 * @Author: jhw
 * @Date: 2023-07-27 14:21:34
 * @LastEditors: jhw
 * @LastEditTime: 2023-07-28 15:30:56
-->
<template>
  <div>
    <el-upload class="upload-demo" action="#" multiple :http-request="uploadFile">
      <el-button type="primary">Click to upload</el-button>
      <template #tip>
        <div class="el-upload__tip">xxxxxxxxxxxxxxxxxx</div>
      </template>
    </el-upload>
  </div>
</template>

<script setup lang="ts">
import { Upload } from '@/utils/upload';
import { UploadRequestOptions } from 'element-plus';

// const options = {
//   reqUrl: '/api/upload_single',
// };

const uploadFile = async (file: UploadRequestOptions) => {
  console.log(file);
  let config = {
    onProgress: (event: ProgressEvent) => {
      console.log(event, '测试');
    },
  };
  const upload = new Upload(file, config);
  const res = await upload.upload();
  console.log(res, '123');

  // upload.onProgress = (event: ProgressEvent) => {
  //   console.log(event);
  // };
  // upload.onProgress();
};
</script>

<style scoped></style>
